Skip to content

fix: correct truncated legacy fingerprint lookup table#24

Merged
bonk-dev merged 1 commit into
bonk-dev:mainfrom
jogibear9988:main
Jul 16, 2026
Merged

fix: correct truncated legacy fingerprint lookup table#24
bonk-dev merged 1 commit into
bonk-dev:mainfrom
jogibear9988:main

Conversation

@jogibear9988

@jogibear9988 jogibear9988 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix a rare failure during legacy S7CommPlus session-key renewal.

Certain PLC challenges selected the final block of a fingerprint lookup table. The table was two bytes too short, causing FingerprintSubProcedure to throw an IndexOutOfRangeException and terminate the connection.

Root cause

Data2Collection[1] contained 4,222 bytes, while its 33 fingerprint operations require 4,224 bytes:

  • 33 operations
  • 128 lookup bytes per operation
  • 4,224 bytes required

The missing final lookup word is 0x4C28.

Changes

  • Complete Data2Collection[1] with the missing 0x4C28 word.
  • Add an invariant test that verifies every fingerprint lookup table is large enough for all its operations.
  • Add an exact regression test for the captured PLC renewal challenge:
    • Challenge: 5B15B4694FC38A775E6778F0770C6E7A3118200D
    • Expected fingerprint: 6AB5811DE6D28746
  • Bump package, assembly, and file versions to 1.1.3.
  • Update the package release notes.

Verification

  • All 122 HarpoS7 tests pass.
  • Release build completes with zero warnings and zero errors.
  • Tested through S7CommPlusDriver against a live PLC using two read-only sessions:
    • Session-key renewal every two seconds for 90 seconds
    • The restored final lookup block was exercised
    • All renewals succeeded
    • Active session completed 88 reads
    • Idle session remained valid and its final read succeeded

No PLC tags were written during testing.

@jogibear9988

Copy link
Copy Markdown
Contributor Author

see also: lircy/S7CommPlusV3Driver#1 (comment)

@jogibear9988

Copy link
Copy Markdown
Contributor Author

can you create a new release after merge?

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (d587055) to head (22b9dc0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #24   +/-   ##
=======================================
  Coverage   98.82%   98.82%           
=======================================
  Files          69       69           
  Lines       57383    57383           
  Branches      290      290           
=======================================
  Hits        56709    56709           
  Misses        520      520           
  Partials      154      154           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Legacy session-key renewal could throw IndexOutOfRangeException in FingerprintSubProcedure when a challenge selected the final lookup block. Data2Collection table 1 contained 4222 bytes although its 33 operations require 4224 bytes.

Restore the missing final lookup word 0x4C28. The captured renewal challenge 5B15B4694FC38A775E6778F0770C6E7A3118200D now derives fingerprint 6AB5811DE6D28746 and can complete authentication instead of terminating the connection.

Add a lookup-table size invariant and an exact regression test for the captured challenge. Bump the package, assembly, and file versions to 1.1.3 and document the fix in the package release notes.
@jogibear9988

Copy link
Copy Markdown
Contributor Author

@bonk-dev FYI: I've included your lib into my S7CommPlus fork

@bonk-dev bonk-dev changed the title Fix final legacy fingerprint lookup block fix: correct truncated legacy fingerprint lookup table Jul 16, 2026

@bonk-dev bonk-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bonk-dev
bonk-dev merged commit 788045d into bonk-dev:main Jul 16, 2026
3 checks passed
@bonk-dev

Copy link
Copy Markdown
Owner

can you create a new release after merge?

I've set up automatic nuget publishing, so every merge now pushes the nugets, as long as you bump the package version.

gijzelaerr added a commit to gijzelaerr/python-snap7 that referenced this pull request Jul 16, 2026
Data2Collection table 1 had 2111 entries (4222 bytes) but its 33
operations require 2112 entries (4224 bytes). The missing final word
0x4C28 caused IndexError during session key renewal when a challenge
selected the last lookup block.

Backported from HarpoS7 commit 22b9dc0 (bonk-dev/HarpoS7#24).

Adds:
- The missing 0x4C28 entry in fp_data2.bin
- Lookup table size invariant test
- Regression test with captured renewal challenge 5B15B469...

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants